Intersoft WebTextEditor Documentation
Customize toolbar programmatically from server-side
See Also Send Feedback
Intersoft WebTextEditor > WebTextEditor > ToolBar > Customize toolbar programmatically from server-side

Glossary Item Box

InitializeToolBar server-side event will be invoked when toolbar is being initialized. In this event, commands can be created, added, or removed from toolbar collection. Main toolbar collection, HTML toolbar collection, Preview toolbar collection, and floating toolbar collection will be passed as the arguments of the event.

The following is the code snippet to add a command to toolbar collection.

C# Copy ImageCopy Code
protected void WebTextEditor1_InitializeToolBar(object sender, ISNet.WebUI.WebTextEditor.WebTextEditorToolBarArgs e)

{
WebTextEditorToolBar tb = e.GetToolBarByCategory(WebTextEditorToolBarCategory.Standard);

if (tb != null)
{
WebTextEditorToolCommandCollection commands = tb.ToolCommands;

WebTextEditorToolCommand cmd = new WebTextEditorToolCommand();
cmd.Name = "cmdEmoticon";
cmd.Text = "Emoticon";
cmd.ToggleGroupName = "TaskPane";
cmd.Type = WebTextEditorToolBarCommandType.ToggleButton;
cmd.DisplayMode = WebTextEditorToolBarCommandDisplayMode.Image;
cmd.Image = "./images/other/smiley1.gif";
commands.Add(cmd);
}
}

 

The following is the code snippet to remove a command from toolbar collection.

 

C# Copy ImageCopy Code
protected void WebTextEditor1_InitializeToolBar(object sender, WebTextEditorToolBarArgs e)

{

WebTextEditorToolBar tb = e.GetToolBarByCategory(WebTextEditorToolBarCategory.Formatting);



if (tb != null)

{

WebTextEditorToolCommandCollection commands = tb.ToolCommands;

commands.Remove(commands.GetNamedItem("cmdFontColor"));

}

}


A toolbar collection could contain multiple toolbars. To easily search for a specific toolbar, GetToolBarByCategory method in the event�??s argument can be used. This method can retrieve toolbar object in the collection using the category and name of toolbar.

WebTextEditorToolBar tb = e.GetToolBarByCategory(WebTextEditorToolBarCategory.Custom, "tbCustom1");

 

In This Section

How-to: Add Custom Command using InitializeToolBar server-side event

How-to: Remove Command using InitializeToolBar server-side event

How-to: Add Custom ToolBar using InitializeToolbar server-side event

How-to: Remove ToolBar using InitializeToolBar server-side event

See Also

©2013. All Rights Reserved.